//
//  SHUserInviteNotesCell.m
//  JiFengDaRen
//
//  Created by SH_iOS on 2017/6/12.
//  Copyright © 2017年 SH_iOS. All rights reserved.
//
#import "SHMyInviteNotesModel.h"
#import "SHUserInviteNotesCell.h"
@interface SHUserInviteNotesCell()
@property (strong, nonatomic)  UIImageView *icon;
@property (strong, nonatomic)  UIImageView *symbolImg;
@property (strong, nonatomic)  UILabel *nameLabel;
@property (strong, nonatomic)  UILabel *phoneLabel;
@property (strong, nonatomic)  UILabel *inviteCountLabel;
@property (strong, nonatomic)  UIView *lineView;

@end
@implementation SHUserInviteNotesCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        _icon = [[UIImageView alloc]init];
        [_icon setCornerRadius:__I6Width(20) bounds:CGRectMake(0, 0, __I6Width(40), __I6Width(40))];
        [self.contentView addSubview:_icon];
        
        _symbolImg = [[UIImageView alloc]init];
        [self.contentView addSubview:_symbolImg];
        
        _nameLabel = [SHLabel labelWithTextFont:15 textColor:KSHTEXTCOLOR textAlignment:NSTextAlignmentLeft];
        [self.contentView addSubview:_nameLabel];
        
        _phoneLabel = [SHLabel labelWithTextFont:12 textColor:[UIColor colorWithHexString:@"#808080"] textAlignment:NSTextAlignmentLeft];
        [self.contentView addSubview:_phoneLabel];
        _inviteCountLabel = [SHLabel labelWithTextFont:12 textColor:KREDCOLOR textAlignment:NSTextAlignmentLeft];
        [self.contentView addSubview:_inviteCountLabel];
        
        _lineView = [[UIView alloc]initWithFrame:CGRectMake(0, __I6Height(59.5), KScreenWidth, 0.5)];
        _lineView.backgroundColor  = KLINECOLOR;
        [self.contentView addSubview:_lineView];

    }
    
    return self;
    
    
}

- (void)layoutSubviews{
    
    [_icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.equalTo(@(__I6Width(40)));
        make.left.mas_equalTo(self.contentView).with.offset(__I6Width(15));
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
    }];
    [_symbolImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@(__I6Width(20)));
        make.height.equalTo(@(__I6Width(20)));
        make.left.mas_equalTo(_icon.mas_right).offset(__I6Width(-10));
        make.top.mas_equalTo(_icon.mas_top).offset(__I6Height(-5));
    }];
    
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@(__I6Height(15)));
        make.left.mas_equalTo(_icon.mas_right).with.offset(__I6Width(15));
        make.top.mas_equalTo(self.contentView.mas_top).with.offset(__I6Height(15));
    }];
    
    [_phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@(__I6Height(13)));
        make.left.mas_equalTo(_icon.mas_right).with.offset(__I6Width(15));
        make.top.mas_equalTo(_nameLabel.mas_bottom).with.offset(__I6Height(5));
    }];
    [_inviteCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@(__I6Height(13)));
        make.right.mas_equalTo(self.contentView.mas_right).with.offset(__I6Width(-15));
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
    }];

    
}

- (void)setMyInviterModel:(SHMyInviteNotesModel *)myInviterModel{
    
    [_icon sd_setImageWithURL:[NSURL URLWithString:myInviterModel.avatar] placeholderImage:[UIImage imageNamed:@"rank_user_default"]];
    
    
    if (myInviterModel.is_agent) {
        [_symbolImg setImage:[UIImage imageNamed:@"isagent"]];
    }else{
        [_symbolImg setImage:[UIImage imageNamed:@"ismember"]];
    }
    
    _nameLabel.text = myInviterModel.nickname;
    _phoneLabel.text = myInviterModel.phone;
    _inviteCountLabel.text = [NSString stringWithFormat:@"%d",myInviterModel.inviter_count];

    
}


@end
